<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>随便打TCS系统</title>

<!-- Bootstrap -->
<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font Awesome -->
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<!-- NProgress -->
<link href="<%=basePath%>vendors/nprogress/nprogress.css"
	rel="stylesheet">
<!-- iCheck -->
<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
	rel="stylesheet">

<!-- bootstrap-progressbar -->
<link
	href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
	rel="stylesheet">
<!-- JQVMap -->
<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
	rel="stylesheet" />
<!-- bootstrap-daterangepicker -->
<link
	href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
	rel="stylesheet">

<!-- Custom Theme Style -->
<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">

</head>
<body class="nav-md">
	<%@ include file="loginCheck.jsp"%>
	<div class="container body">
		<div class="main_container">
			<div class="col-md-3 left_col">
				<div class="left_col scroll-view">
					<div class="clearfix"></div>
					<br />
				</div>
			</div>
			<!-- page content -->
			<div class="right_col" role="main">
				<div class="">
					<div class="clearfix"></div>
					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="x_panel">
								<div class="x_content">
									<form name="myForm" class="form-horizontal form-label-left"
										novalidate method="post" enctype="multipart/form-data"
										id="myForm">
										<span class="section">联系我们</span>
										<div class="item form-group" style="display: none">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">id<span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="id" name="id"
													class="form-control col-md-7 col-xs-12" type="text"
													value="${abouts.id}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">客服电话 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="number"
													placeholder="例如：0571-123456" required="required"
													type="text" value="${abouts.number}" id="number">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">客服QQ </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="qq"
													   placeholder="例如：0571-123456" required="required"
													   type="text" value="${abouts.qq}" id="qq">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">客服微信 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="wechat"
													placeholder="例如：13654265123" required="required"
													type="text" value="${abouts.wechat}" id="wechat">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">工作时间 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="time"
													placeholder="例如：24677111" required="required" type="text"
													value="${abouts.time}" id="time">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">公众号图片 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" id="file"
													name="file" required="required" type="file"
													placeholder="请先上传图片" form="formUpload"> <input
													id="pic" name="pic" class="form-control col-md-7 col-xs-12"
													style="display: none" type="text" value="${abouts.pic}">
											</div>
										</div>
										<div class="form-group">
											<div class="col-md-6 col-md-offset-3">
												<input id="revise" type="button" class="btn btn-success"
													value="确定" />
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- /page content -->
	<!-- 上传图片并修改 -->
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<script type="text/javascript">
		$('#revise').click(function () {
			// 上传文件
			var file = $("#file")[0].files[0];
		    if(file != null || file != undefined){
		    	var fileName = file.name.substring(file.name.lastIndexOf(".")+1).toLowerCase();
				if(fileName !="jpg" && fileName !="jpeg" && fileName !="png"&& fileName !="gif" ){
					alert("只能上传 .jpg .png .jpeg .gif类型的文件");
		            return false;
				}
		    	$("#pic").val(addfile(file));
			}
			var json = {};
			json.id = $("#id").val();
			json.qq = $("#qq").val();
			json.number = $("#number").val();
			json.wechat = $("#wechat").val();
			json.time = $("#time").val();
			json.pic = $("#pic").val();
		    $.ajax({
				type : 'POST',
				url : 'abouts_do_update',
				data : JSON.stringify(json),
				dataType: 'json',
				contentType: 'application/json',
				success : function(date) {
					switch (date) {
					case -1:
						alert("登录超时，请重新登录");
						top.location.href = "login/${titleId}";
						break;
					case 1:
						alert("修改成功");
						location.href = "abouts_index";
						break;
					default:
						alert("修改失败，请重新操作");
						break;
					}
				},
				error : function() {
					alert("修改失败，请重新操作");
			    }
			});
		});
		
		function addfile(file) {
			var fm = new FormData();
			fm.append('file', file);
			$.ajax({
				url: '<%=basePath%>layfile/uploadFile1',
				type : 'POST',
				data : fm,
				async : false,
				contentType : false, //禁止设置请求类型
				processData : false, //禁止jquery对DAta数据的处理,默认会处理
				//禁止的原因是,FormData已经帮我们做了处理
				success : function(result) {
					file = result.json;
				}
			});
			return file;
		}
	</script>
	<!-- Bootstrap -->
	<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
	<!-- bootstrap-daterangepicker -->
	<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
	<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
	<!-- Chart.js -->
	<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
	<!-- Custom Theme Scripts -->
	<script src="<%=basePath%>build/js/custom.min.js"></script>
</body>
</html>